package com.beinfo.contract.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.beinfo.contract.dao.UserDao;
import com.beinfo.contract.model.User;
import com.beinfo.contract.service.UserService;

//import cn.edu.zucc.news.model.WebUserDAO;

//import cn.edu.zucc.news.model.WebUser;



public class UserServlet extends HttpServlet {
    private UserDao dao = new UserDao();

    

    protected void doGet(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {
        //TODO Method stub generated by Lomboz
        this.doPost(request, response);
    }
	
	private String logincheck(HttpServletRequest request) {
        try {
            String userid=request.getParameter("username");
            if(userid==null ||userid.equals(""))
                throw new Exception("请输入用户名");
            String pwd=request.getParameter("password");
            if(pwd==null)pwd="";
            User user=dao.readUser(userid);
            if(user==null) 
                throw new Exception("用户不存在");
            if(!pwd.equals(user.getPwd()))
                throw new Exception("密码错误");
            request.getSession().setAttribute("username",user.getUsername());
            if("admin".equals(user.getUsertype()))
               return "/main.jsp";
            else
                return "/main.jsp";
        } catch (Exception ex) {
            request.setAttribute("errormsg", ex.getMessage());
            return "/login.jsp";
        }
    }

	
	
		
	
}



